package cn.edu.javaweb.superServlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.javaweb.utils.DBUtil;
@WebServlet("/UpdateNotice")
public class UpdateNotice extends HttpServlet {
	private static final long serialVersionUID = 1L;
	DBUtil db; //声明对象 一定要赋值  否则空指针异常
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//设置Register.html里的编码
		String title=request.getParameter("title");
		String content=request.getParameter("content");
		String target=request.getParameter("target");
		String place=request.getParameter("place");
		String Stime=request.getParameter("Stime");
		String Etime=request.getParameter("Etime");
		System.out.println(title);
		

		db=new DBUtil(); //建创对象 搭桥配置初始化
		db.init();
	
		String id = request.getParameter("id"); 
		String sql="update notice set title='"+title+"',content='"+content+"',target='"+target+"',place='"+place+"',Stime='"+Stime+"',Etime='"+Etime+"' where id='"+id+"'"; //写入sql语句
		
		System.out.println(sql); 
		int result = db.update(sql);
		//防止出现乱码状况
		response.sendRedirect("/Volunteer/SelectNotice");
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response); 
	}

}
